package com.itheima.controller;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;

@Controller
public class FirstController{

//	@RequestMapping(value = "/firstController",method = RequestMethod.GET)
//	public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
//		// TODO Auto-generated method stub
//		ModelAndView mav=new ModelAndView();
//		mav.addObject("msg","这是我的第一个Spring MVC程序");
//		mav.setViewName("/WEB-INF/jsp/first.jsp");
//		System.out.println("this is a controller");
//		return mav;
//	}
	@RequestMapping(value = "/firstController",method = RequestMethod.GET)
	public String handle(Model model) throws Exception{
		model.addAttribute("msg","这是我的第一个Spring MVC程序");
		return "first";
	}
	@RequestMapping(value = "/testdata",method = RequestMethod.GET)
	@ResponseBody
	public String testdata() {
		return "testdata";
	}
}
